<template>
  <view class="bg-white">
    <cu-custom
      bgColor="bg-white"
      :isBack="true"
    >
      <block slot="content">转正申请详情</block>
    </cu-custom>
    <view class="padding bg-white">
      <view
        class="text-cut padding"
        style="background-color: #f3f5fc;color: #4591fe;border-radius: 15px;"
      >
        创建日期：{{dataObj.createTime != null ? dataObj.createTime.replace(/\-/g, "/") : null}}
      </view>
    </view>
    <view class="cu-bar bg-white solid-bottom">
      <view class="action">
        <text
          class="cuIcon-titles "
          style="color: #1E5EFF;"
        ></text> 基础信息
      </view>
    </view>
    <view>
      <view class="flex">
        <view class="flex-sub padding-sm margin-xs radius">
          公司
        </view>
        <view class="flex-sub padding-sm margin-xs radius">
          <view style="background-color: #f9f9f9;padding: 5px 10px;margin-top: -5px;">
            <image
              src="../../../static/gongsi.png"
              style="width: 10px;height: 10px;margin-right: 5px;"
            >
            </image>
            <text>
              {{dataObj.company_dictText}}
            </text>
          </view>
        </view>
      </view>
      <view class="flex">
        <view class="flex-sub padding-sm margin-xs radius">
          工号
        </view>
        <view class="flex-sub padding-sm margin-xs radius">
          {{dataObj.workNo}}
        </view>
      </view>
      <view class="flex">
        <view class="flex-sub padding-sm margin-xs radius">
          姓名
        </view>
        <view class="flex-sub padding-sm margin-xs radius">
          {{dataObj.realname}}
        </view>
      </view>
      <view class="flex">
        <view class="flex-sub padding-sm margin-xs radius">
          性别
        </view>
        <view class="flex-sub padding-sm margin-xs radius">
          {{dataObj.sex_dictText}}
        </view>
      </view>
      <view class="flex">
        <view class="flex-sub padding-sm margin-xs radius">
          年龄
        </view>
        <view class="flex-sub padding-sm margin-xs radius">
          {{dataObj.age}}
        </view>
      </view>
      <view class="flex">
        <view class="flex-sub padding-sm margin-xs radius">
          入职时间
        </view>
        <view class="flex-sub padding-sm margin-xs radius">
          <!-- {{dataObj.workStartTime}} -->
          {{dataObj.workStartTime != null ? dataObj.workStartTime.replace(/-/g,'/') : null}}
        </view>
      </view>
      <view class="flex">
        <view class="flex-sub padding-sm margin-xs radius">
          部门
        </view>
        <view class="flex-sub padding-sm margin-xs radius">
          <view style="background-color: #f9f9f9;padding: 5px 10px;margin-top: -5px;">
            <image
              src="../../../static/gongsi.png"
              style="width: 10px;height: 10px;margin-right: 5px;"
            >
            </image>
            <text>
              {{dataObj.orgCodeTxt}}
            </text>
          </view>
        </view>
      </view>
      <!-- <view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					车间
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.workshop}}
				</view>
			</view> -->
      <view class="flex">
        <view class="flex-sub padding-sm margin-xs radius">
          岗位
        </view>
        <view class="flex-sub padding-sm margin-xs radius">
          {{dataObj.post}}
        </view>
      </view>
      <!-- <view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					班次
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.classes}}
				</view>
			</view> -->
      <view class="flex">
        <view class="flex-sub padding-sm margin-xs radius">
          试用期时长（月）
        </view>
        <view class="flex-sub padding-sm margin-xs radius">
          {{dataObj.probationPeriodDuration}}
        </view>
      </view>
      <view class="flex">
        <view class="flex-sub padding-sm margin-xs radius">
          转正日期
        </view>
        <view class="flex-sub padding-sm margin-xs radius">
          <!-- {{dataObj.regularDate}} -->
          {{dataObj.regularDate != null ? dataObj.regularDate : null}}
        </view>
      </view>
      <view class="flex">
        <view class="flex-sub padding-sm margin-xs radius">
          试用期工资(元/月)
        </view>
        <view class="flex-sub padding-sm margin-xs radius">
          {{dataObj.probationSalary}}
        </view>
      </view>
      <view class="flex">
        <view class="flex-sub padding-sm margin-xs radius">
          转正工资(元/月)
        </view>
        <view class="flex-sub padding-sm margin-xs radius">
          {{dataObj.regularSalary}}
        </view>
      </view>

    </view>
    <!-- <view>
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					经办人
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.handledBy}}
				</view>
			</view>

		</view> -->

    <view style="margin-top: 15px;">
      <view
        class="action"
        style="margin-bottom: 10px;"
      >
        <text
          class="cuIcon-titles "
          style="color: #1E5EFF;"
        ></text>
        <text style="color: #000000;font-weight: bold;font-size: 30rpx;">
          审批记录
        </text>
      </view>
      <view style="background-color: #f4f4f4;border-radius: 10px;margin-top: 10px;">
        <view
          class="cu-timeline"
          v-for="(item,index) in approvalRecords"
          :key="index"
        >
          <view class="cu-item text-green cuIcon-roundcheckfill">
            <view style="display: flex;color: #000000;">
              <view style="width: 25px;">
                <text style="margin-left: -18px;margin-top: 5px;display: block;font-weight: bold;">{{item.currentNodeDictText}}</text>
              </view>
              <view style="margin-left: 20px;">
                <view>
                  <text style="font-size: 28rpx;">{{item.approverDictText}}</text>
                  <text style="display: inline-block;padding: 2px;background-color: #d9d9d9;border-radius: 5px;font-size: 16rpx;margin-left: 10px;color: #a1a1a1;">{{item.remark}}</text>
                  <text
                    v-if="item.approvalStatusDictText == '同意'"
                    style="display: inline-block;padding: 4rpx 10rpx;background-color: #34b483;border-radius: 5px;font-size: 16rpx;margin-left: 15px;color: #FFFFFF;"
                  >{{item.approvalStatusDictText}}</text>
                  <text
                    v-if="item.approvalStatusDictText == '待审'"
                    style="display: inline-block;padding: 4rpx 10rpx;background-color: #c6ffbe;border-radius: 5px;font-size: 16rpx;margin-left: 15px;color: #48B237;"
                  >{{item.approvalStatusDictText}}</text>
                  <text
                    v-if="item.approvalStatusDictText == '驳回'"
                    style="display: inline-block;padding: 4rpx 10rpx;background-color: #f5222d;border-radius: 5px;font-size: 16rpx;margin-left: 15px;color: #FFFFFF;"
                  >{{item.approvalStatusDictText}}</text>
                  <text
                    v-if="item.approvalStatusDictText == '结束'"
                    style="display: inline-block;padding: 4rpx 10rpx;background-color: #D9D9D9;border-radius: 5px;font-size: 16rpx;margin-left: 15px;color: #A0A0A0;"
                  >{{item.approvalStatusDictText}}</text>
                </view>
                <view>
                  <text style="font-size: 24rpx;">{{item.approvalTypeDictText}}</text>
                  <text style="font-size: 20rpx;color: #c7c7c7;margin-left: 15px;">{{item.createTime}}</text>
                </view>
              </view>

            </view>
          </view>
        </view>
      </view>
    </view>
    <view
      v-if="isShowBtn"
      style="display: flex;justify-content: space-around;align-items: center;padding-top: 20rpx;padding-bottom: 20rpx;"
    >
      <view @click.stop="agree()">
        <button style="background-color: rgba(69, 145, 254, 1);border-radius: 20rpx;font-size:12px;padding: 10rpx 70rpx;color: rgba(255, 255, 255, 1);display: inline-block; ">同意</button>
      </view>
      <view @click.stop="disagree()">
        <button style="background-color: rgba(167, 52, 52, 1);border-radius: 20rpx;font-size:12px;padding: 10rpx 70rpx;color: rgba(255, 255, 255, 1);display: inline-block;">驳回</button>
      </view>
    </view>

    <uni-popup
      ref="agreePopup"
      background-color="#fff"
      :mask-click="false"
    >
      <view style="text-align: center;background-color: #FFFFFF;padding: 11rpx;width: 580rpx;height: 470rpx;border-radius: 42rpx;">
        <view class="submit-item">
          <image
            class="submit-icon"
            src="@/static/images/editUserIcon.png"
          />
        </view>
        <view style="margin-top: 28rpx;">
          <text class="submit-text">确定要同意该申请吗</text>
        </view>
        <br>
        <view style="display: flex;">
          <button
            @click="sureAgree"
            style="border-radius: 20rpx; background-color: rgba(69, 145, 254, 1);
						color: rgba(255, 255, 255, 1);width: 230rpx;margin-top: 50rpx;"
          >确定</button>
          <button
            @click="cancelAgree"
            style="border-radius: 20rpx; background-color: gray;
						color: rgba(255, 255, 255, 1);width: 230rpx;margin-top: 50rpx;"
          >取消</button>
        </view>
      </view>
    </uni-popup>
    <uni-popup
      ref="isAgree"
      background-color="#fff"
      :mask-click="false"
    >
      <view style="text-align: center;background-color: #FFFFFF;padding: 11rpx;width: 580rpx;height: 470rpx;border-radius: 42rpx;">
        <view class="submit-item">
          <image
            class="submit-icon"
            src="@/static/zhinengshenheshenchashenhe 1.png"
          />
        </view>
        <view style="margin-top: 28rpx;">
          <text class="submit-text">你已同意用户的申请</text>
        </view>
        <button
          @click="agreeCancel"
          style="border-radius: 20rpx; background-color: rgba(69, 145, 254, 1);
			color: rgba(255, 255, 255, 1);width: 300rpx;margin-top: 27rpx;"
        >确定</button>
      </view>
    </uni-popup>
    <uni-popup
      ref="isDisagree"
      background-color="#fff"
      :mask-click="false"
    >
      <view style="background-color: #FFFFFF;padding: 11rpx 30rpx;width: 580rpx;height: 400rpx;border-radius: 42rpx;">
        <view style="margin-top: 28rpx;margin-left: 15rpx;">
          <text class="submit-text">驳回</text>
        </view>
        <view
          class="cu-form-group"
          style="background-color: rgba(243, 243, 243, 1);border-radius: 15px;margin-top: 40rpx;height: 100rpx;"
        >
          <input
            v-model="rejectReason"
            placeholder="请输入驳回理由"
            name="input"
            style="font-size: 25rpx;"
          ></input>
        </view>
        <button
          style="background-color: rgba(217, 217, 217, 1);
						color: rgba(86, 85, 85, 1); margin-top: 30rpx;padding: 2rpx 85rpx; display: inline-block; "
          @click="rejectCancel"
        >取消</button>
        <button
          style="background-color: rgba(69, 145, 254, 1);
			color: rgba(255, 255, 255, 1);margin-left:34rpx; display: inline-block;padding: 2rpx 85rpx; "
          @click="rejectSure"
        >确定</button>
      </view>
    </uni-popup>
  </view>
</template>

<script>
import moment from 'moment';
export default {
  data () {
    return {
      isShowBtn: false,
      examineId: '',
      rejectReason: '',
      createTime: '2023/10/10 ',
      dataObj: {
        title: '福建省立华智纺科技',
        building: '1栋',
        floor: '3层',
        dormitoryProperties: '高管房',
        dormitoryNumber: '301',
        habitable: '4',
        resided: '2',
        isFull: '是',
        handledBy: '小张',
        updateUser: '张果冻',
        updateTime: '2023/10/10',
        workNumber: '123344',
        name: '小张',
        sex: '男',
        age: '23',
        workTime: '2023/10/10',
        department: '细沙-XS',
        workshop: '某某车间',
        station: '某某岗位',
        classes: '某某班次',

      },
      approvalRecords: [{
        title: '总经理',
        name: '陈婷婷',
        area: '手写区域',
        state: '同意',
        manager: '企管',
        dateTime: '2023/10/10 12:00'
      }, {
        title: '车间',
        name: '陈婷婷',
        area: '手写区域',
        state: '同意',
        manager: '企管',
        dateTime: '2023/10/10 12:00'
      }, {
        title: '填写申请单',
        name: '陈婷婷',
        area: '手写区域',
        state: '提交',
        manager: '企管',
        dateTime: '2023/10/10 12:00'
      }]
    }
  },
  mounted () {
    this.getDetail()
  },
  computed: {

  },
  onLoad: function (options) {
    this.dataObj.id = options.id;
    // 在这里可以使用获取到的 id 参数进行后续操作
    if (options.status && options.status == 3) {
      this.isShowBtn = true
      this.examineId = options.examineId
    } else {
      this.isShowBtn = false
      this.examineId = options.examineId
    }
  },
  methods: {
    agree () {
      // this.examineId = item.id
      this.$refs.agreePopup.open('center')
    },
    disagree () {
      // this.examineId = item.id
      this.$refs.isDisagree.open('center')
    },
    sureAgree () {
      this.$http.post("/crm_on_hand/crmOnHand/agreeTrial", {
        id: this.examineId
      }).then(res => {
        console.log('同意申请', res)
        if (res.data.success) {
          this.$refs.isAgree.open('center')
          this.$refs.agreePopup.close()
          let that = this
          setTimeout(() => {
            that.agreeCancel()
            uni.navigateTo({
              url: '/pages/toDoList/index'
            })
          }, 1000)

        } else {
          this.$tip.toast(res.data.message)
          this.$refs.agreePopup.close()
        }
      })
    },
    cancelAgree () {
      this.$refs.agreePopup.close()
    },
    agreeCancel () {
      this.$refs.isAgree.close()
    },
    rejectCancel () {
      this.$refs.isDisagree.close()
    },
    rejectSure () {
      this.$http.post("/crm_on_hand/crmOnHand/rejectTrial", {
        id: this.examineId,
        reason: this.rejectReason
      }).then(res => {
        if (res.data.success) {
          this.$refs.isDisagree.close()
          setTimeout(() => {
            uni.navigateTo({
              url: '/pages/toDoList/index'
            })
          }, 1000)
        } else {
          this.$tip.toast(res.data.message)
          this.$refs.isDisagree.close()
        }
      })
    },
    getDetail () {
      this.$http.get(
        "/crm_become_regular_application/crmBecomeRegularApplication/queryEmploymentApplicationDetail/" + this.dataObj.id)
        .then(res => {
          if (res.data.success) {
            this.dataObj = res.data.result
            // this.dataObj['avatar'] = this.getFileAccessHttpUrl(this.dataObj['avatar'])
            // console.log(this.dataObj['avatar'])
            this.approvalRecords = this.dataObj.approvalRecords
          }
        })
    },
    searchBtn () {
      console.log(this.searchValue)
    },

  }
}
</script>

<style lang="scss" scoped>
.submit-icon {
  width: 118rpx;
  height: 118rpx;
  margin-top: 58rpx;
}
image {
  width: 100%;
  height: 100%;
}

.blackList {
  height: 100%;
  overflow: hidden;
}

.page-search {
  padding-left: 34rpx;
  margin-bottom: 12rpx;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.search {
  width: 680rpx;
  height: 86rpx;
  background-color: rgba(249, 249, 249, 1);
  border-radius: 60rpx;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding-left: 24rpx;
  padding-right: 24rpx;

  .search-left {
    width: 28rpx;
    height: 28rpx;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .search-center {
    margin-left: 22rpx;
  }

  .search-placeholder {
    font-size: 28rpx;
    font-weight: 400;
    color: #7c7c7c;
  }
}

.filter-btn {
  width: 40rpx;
  height: 40rpx;
  margin-right: 42rpx;
  display: flex;
  justify-content: center;
  align-items: center;
}

.page-content-main {
  height: calc(100% - 12rpx - 86rpx);
  border-top-left-radius: 64rpx;
  border-top-right-radius: 64rpx;
  padding: 26rpx 34rpx 0 34rpx;
}

.select-box {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
}

.select {
  width: 160rpx;
  height: 74rpx;
  border-radius: 60rpx;
  background-color: #4591fe;
  margin-bottom: 20rpx;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  margin-right: 48rpx;
  position: relative;

  .select-value {
    font-size: 28rpx;
    font-weight: 400;
    color: #ffffff;
    margin-right: 18rpx;
  }

  .select-icon {
    width: 22rpx;
    height: 22rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    right: 20rpx;
    top: 25rpx;
  }
}

.list {
  height: calc(100% - 74rpx - 20rpx);
}

.list-item {
  border-radius: 28rpx;
  background-color: #ffffff;
  padding: 26rpx 24rpx 28rpx 20rpx;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  margin-bottom: 26rpx;
  position: relative;

  .list-item-leftCenter {
    display: flex;
    flex-direction: row;
  }

  .list-item-left {
    width: 86rpx;
    height: 86rpx;
    margin-right: 26rpx;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .list-item-center {
    .list-item-row {
      display: flex;
      flex-direction: row;
      margin-bottom: 20rpx;

      .list-item-name {
        color: #101317;
        font-size: 32rpx;
        margin-right: 16rpx;
      }

      .list-item-sex {
        width: 106rpx;
        height: 42rpx;
        border-top-right-radius: 40rpx;
        border-bottom-right-radius: 40rpx;
        border-bottom-left-radius: 20rpx;
        background-color: rgba(234, 171, 78, 0.35);
        line-height: 42rpx;
        text-align: center;
        color: rgba(255, 173, 4, 1);
        font-size: 24rpx;
      }

      .list-item-row-icon {
        width: 38rpx;
        height: 38rpx;
        margin-right: 10rpx;
        display: flex;
        justify-content: center;
        align-items: center;
      }

      .list-item-row-title,
      .list-item-row-value {
        font-size: 24rpx;
        font-weight: 400;
        color: #101317;
        line-height: 38rpx;
      }
    }
  }

  .list-item-btn {
    width: 36rpx;
    height: 36rpx;
    margin-top: 56rpx;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .list-item-tab {
    width: 132rpx;
    height: 56rpx;
    text-align: center;
    line-height: 56rpx;
    background-color: rgba(69, 145, 254, 0.4);
    position: absolute;
    top: 0;
    right: 0;
    border-top-right-radius: 26rpx;
    border-bottom-left-radius: 20rpx;
  }

  .list-item-tab-text {
    font-size: 26rpx;
    color: rgba(69, 145, 254, 1);
  }
}

.nav-right-image {
  width: 80rpx;
  height: 80rpx;
  margin-left: 15px;
}

.cu-form-group {
  background-color: transparent;
}

::v-deep {
  .cu-form-group uni-picker .picker {
    color: #ffffff;
  }

  .cu-form-group uni-picker::after {
    opacity: 0;
  }
}

.textView {
  margin-left: 25px;
  font-size: 10px;
  margin-top: 5px;
}

.listText {
  width: 148rpx;
  height: 24rpx;
  font-size: 20rpx;
  font-family: PingFang SC, PingFang SC;
  font-weight: 400;
  color: #000000;
  line-height: 24rpx;
}
</style>
